package com.take.web.controller;

import java.util.Arrays;
import java.util.List;

import lombok.Data;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/")
public class TestController {

	@Data
	public static class User {
		String name;
		String password;

		public User() {

		}

		public User(String name, String password) {
			this.name = name;
			this.password = password;
		}

	}

	@RequestMapping("jsp")
	public ModelAndView jsp() {

		return new ModelAndView("test", "model", "hello world");
	}

	/**
	 * 不建议用ModelAndView
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "jsp2")
	public String jsp2(Model model) {

		// 默认名称策略 参考： Conventions.getVariableName()方法
		model.addAttribute("hello worlds jsp2 ");

		return "test";

	}

	@RequestMapping(value = "jsp3")
	public List<String> jsp2() {

		return Arrays.asList("2222", "xxxxxx");

	}

	@RequestMapping(value = "login")
	public String index() {
		return "login";
	}

}
